package cn.xiyan.baas.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.xiyan.baas.entity.User;
import cn.xiyan.baas.mapper.UserMapper;
import cn.xiyan.baas.service.IUserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author ruiyanglee
 * @since 2020-08-19
 */
@Service
@Transactional(propagation = Propagation.NESTED, isolation = Isolation.DEFAULT)
// Propagation.NESTED: 支持当前事务，如果当前没有事务，就新建一个事务。
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    @Resource
    private UserMapper userMapper;


    @Override
    public User findById(String id) {
        return userMapper.selectById(id);
    }

    @Override
    public IPage<User> selectPage(Page<User> page, QueryWrapper<User> query) {
        return userMapper.selectPage(page, query);
    }
}
